package com.example.baiduapi.Mapper.mysqlMapper;

import com.example.baiduapi.pojo.Chatmessage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface MessageMapper {

    @Insert("insert into TGMessage(ID,message) values (#{ID},#{message})")
    Integer insertTDmessage(String ID,String message);
    @Select("select count(1) from TGMessage where message = #{message}")
    Integer countMessage(String message);
    @Insert({"call 信息新增(" +
            "#{ID,mode=IN,jdbcType=VARCHAR}," + // 发送ID
            "#{messageID,mode=IN,jdbcType=VARCHAR}," + // 消息ID
            "#{createUser,mode=IN,jdbcType=VARCHAR}," + // 发送用户ID
            "#{comment,mode=IN,jdbcType=VARCHAR}," + // 发送备注
            "#{lookState,mode=IN,jdbcType=VARCHAR}," + // 已读状态
            "#{showState,mode=IN,jdbcType=VARCHAR}," + // 可见状态
            "#{message,mode=IN,jdbcType=VARCHAR}," +  // 信息内容
            "#{initiCreateUser,mode=IN,jdbcType=VARCHAR}," + // 初始信息创建用户ID
            "#{LongTime,mode=IN,jdbcType=VARCHAR}," +    // 长时消息ID
            "#{initComment,mode=IN,jdbcType=VARCHAR}," + // 初始信息创建备注
            "#{getUser,mode=IN,jdbcType=VARCHAR}" + // 初始信息创建备注
            ")"
    })
    Integer addmessage(Chatmessage chatmessage);

    /**
     * 获取所有和自己相关的信息
     * @param ID 自己ID
     * @return
     */
    List<Map<String,String>> getAlluserMessages(String ID);
    /**
     * 获取所有和自己相关的信息
     * @param ID 自己ID
     * @param Begintime 最找消息时间
     * @param EndTime 最晚消息时间
     * @return
     */
    List<Map<String,String>> getAlluserMessagesByTime(String ID,String Begintime,String EndTime);
    List<Map<String,String>> getAlluserMessagesUserByTime(String ID,String Begintime,String EndTime);
}
